/**
 * 系统设置页
 * @author hongwei 2018-09-08
 */
(function (window) {
    'use strict';
    var systemIndex = function () {
        this._init();   //初始化操作
    };

    systemIndex.prototype = {
        _init: function () {
            var that = this;
            that.aboutUs();         //step1:关于我们
            that.version();         //step2:应用版本号
            that.logOut();          //step3:退出
            that.getCacheSize();    //step4:获取缓存大小
        }

        //step1:关于我们
        , aboutUs: function () {
            $('#aboutUs').click(function () {
                openWin('about_us', './about_us_win.html');
            });
        }

        //step2:应用版本号
        , version: function () {
            var version = api.appVersion;
            $('#version').text(version);
        }

        //step3:退出
        , logOut: function () {
            $("#logOut").click(function () {

                var dialog = new auiDialog();
                dialog.alert({
                    msg: '确定要退出登录吗？',
                    buttons: ['取消', '确定']
                }, function (ret) {
                    if (ret.buttonIndex === 2) {
                        api.closeWin({
                            name: 'main'
                        });

                        //清空session跳转到登录页面
                        $api.clearStorage();
                        api.openWin({
                            name: 'login',
                            url: '../../login/login.html',
                            slidBackEnabled: false
                        });
                    }
                })
            });
        }

        //step4:获取缓存大小
        ,getCacheSize : function () {
            api.getCacheSize(function(ret) {
                var size = ret.size;
                var sizeType = size/(1024*1024);
                sizeType = sizeType.toFixed(2);
                $('#cacheSize').empty().text(sizeType+'MB');
            });
        }
    };
    window.systemIndex = systemIndex;
})(window);